package com.yuke.cloud.service.wmc.controller.frontend;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuke.cloud.common.util.wrapper.WrapMapper;
import com.yuke.cloud.common.util.wrapper.Wrapper;
import com.yuke.cloud.service.api.pmc.dto.ProdCategoryDto;
import com.yuke.cloud.service.wmc.dto.PaymentOrderDto;
import com.yuke.cloud.service.wmc.dto.WmsFlowDto;
import com.yuke.cloud.service.wmc.dto.WmsGoodsSalesDto;
import com.yuke.cloud.service.wmc.dto.WmsStatisticsDto;
import com.yuke.cloud.service.wmc.entity.WmsStockIn;
import com.yuke.cloud.service.wmc.service.WmsPurchaseOrderService;
import com.yuke.cloud.service.wmc.service.WmsStockInService;
import com.yuke.cloud.service.wmc.service.WmsStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zn on 2020/10/14.
 */
@Api(value = "WEB - WmsStatisticsController", tags = "统计", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
@RequestMapping("/wms/statistics")
//统计
public class WmsStatisticsController {


    @Resource
    private WmsPurchaseOrderService wmsPurchaseOrderService;

    @Resource
    private WmsStorageService wmsStorageService;

    @Resource
    private WmsStockInService wmsStockInService;

    /*
    进货单统计:需总价格处于总数量 算出单价
     */
    @PostMapping("/costUnitPrice")
    @ApiOperation(httpMethod = "POST", value = "根据分类计算单个商品成本均价")
    public Wrapper<PageInfo<WmsStatisticsDto>> costUnitPrice(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "0") Integer page,
                                                         @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "0") Integer size,
                                                         @ApiParam(name = "wmsStatisticsDto", value = "wmsStatisticsDto", defaultValue = "0") @RequestBody WmsStatisticsDto wmsStatisticsDto

    ){

        PageInfo<WmsStatisticsDto> list =wmsPurchaseOrderService.costUnitPrice(wmsStatisticsDto,page,size);

        return WrapMapper.ok(list);
    }


/*    库存状况表:需总价格处于总数量 算出单价
    根据specId Category*/
    @PostMapping("/storageAndUnitPrice")
    @ApiOperation(httpMethod = "POST", value = "根据分类计算单个商品成本均价")
    public Wrapper<PageInfo<WmsStatisticsDto>> storageAndUnitPrice(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "0") Integer page,
                                                             @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "0") Integer size,
                                                             @ApiParam(name = "wmsStatisticsDto", value = "wmsStatisticsDto", defaultValue = "0") @RequestBody WmsStatisticsDto wmsStatisticsDto

    ){

        PageInfo<WmsStatisticsDto> list = wmsStorageService.storageAndUnitPrice(wmsStatisticsDto,page,size);


        return WrapMapper.ok(list);
    }

/*    //商品销售排行榜
    @PostMapping("/goodsSales")
    @ApiOperation(httpMethod = "POST", value = "计算单个商品成本均价")
    public Wrapper<PageInfo<WmsGoodsSalesDto>> goodsSales(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "0") Integer page,
                                                          @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "0") Integer size,
                                                          @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestBody WmsGoodsSalesDto goodsSalesDto

    ){


        PageInfo<WmsGoodsSalesDto> goodsSalesDtoPageInfo = wmsStockInService.goodsSales(page, size, goodsSalesDto);


        return WrapMapper.ok(goodsSalesDtoPageInfo);
    }*/


    //商品销售排行榜
    @PostMapping("/goodsSales")
    @ApiOperation(httpMethod = "POST", value = "计算单个商品成本均价")
    public Wrapper<PageInfo<WmsGoodsSalesDto>> goodsSales(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "0") Integer page,
                                                          @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "0") Integer size,
                                                          @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestBody WmsGoodsSalesDto goodsSalesDto

    ){


        PageInfo<WmsGoodsSalesDto> goodsSalesDtoPageInfo = wmsStockInService.goodsSalesJoin(page, size, goodsSalesDto);

        return WrapMapper.ok(goodsSalesDtoPageInfo);
    }


}
